package com.sina.weibo.view;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.text.SpannableStringBuilder;
import android.text.TextPaint;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.TextView.BufferType;
import com.sina.weibo.RPCHelper;
import com.sina.weibo.Utils;
import com.sina.weibo.models.CommentMessage;
import java.io.File;
import java.util.Date;
import java.util.Hashtable;
import java.util.Map;

public class CommentMessageListItemView extends LinearLayout
  implements MainListItemView
{
  private static Map<String, ListView> downloading = new Hashtable();
  private CommentMessage cm;
  private Context context;
  private String mCacheDir;
  private TextView mContent;
  private TextView mDate;
  private TextView mName;
  private ImageView mPortrait;
  private int mReadMode;
  private TextView mSubContent;
  private ListView parent;

  public CommentMessageListItemView(Context paramContext, ListView paramListView, CommentMessage paramCommentMessage, boolean paramBoolean1, boolean paramBoolean2, boolean paramBoolean3, int paramInt)
  {
    super(paramContext);
    this.context = paramContext;
    this.parent = paramListView;
    String str = paramContext.getCacheDir().getAbsolutePath();
    this.mCacheDir = str;
    View localView = ((LayoutInflater)paramContext.getSystemService("layout_inflater")).inflate(2130903057, this);
    TextView localTextView1 = (TextView)findViewById(2131623996);
    this.mName = localTextView1;
    TextView localTextView2 = (TextView)findViewById(2131624022);
    this.mDate = localTextView2;
    TextView localTextView3 = (TextView)findViewById(2131623998);
    this.mContent = localTextView3;
    TextView localTextView4 = (TextView)findViewById(2131624026);
    this.mSubContent = localTextView4;
    ImageView localImageView = (ImageView)findViewById(2131623993);
    this.mPortrait = localImageView;
    this.mReadMode = paramInt;
    CommentMessageListItemView localCommentMessageListItemView = this;
    CommentMessage localCommentMessage = paramCommentMessage;
    boolean bool1 = paramBoolean1;
    boolean bool2 = paramBoolean2;
    int i = paramInt;
    localCommentMessageListItemView.update(localCommentMessage, bool1, bool2, 0, i);
  }

  private void displayDefaultPortrait()
  {
    ImageView localImageView = this.mPortrait;
    Context localContext = this.context;
    Bitmap localBitmap1 = Utils.outputRoundRectBitmap(BitmapFactory.decodeResource(this.context.getResources(), 2130838011));
    Bitmap localBitmap2 = Utils.outputBmp(localContext, localBitmap1, 0);
    localImageView.setImageBitmap(localBitmap2);
  }

  public void update(Object paramObject, boolean paramBoolean1, boolean paramBoolean2, boolean paramBoolean3, int paramInt)
  {
    CommentMessage localCommentMessage = (CommentMessage)paramObject;
    this.cm = localCommentMessage;
    findViewById(2131624025).setVisibility(0);
    SpannableStringBuilder localSpannableStringBuilder1 = new SpannableStringBuilder();
    if (localCommentMessage.srccontent != null)
    {
      String str1 = getResources().getString(2131427503);
      SpannableStringBuilder localSpannableStringBuilder2 = localSpannableStringBuilder1.append(str1).append(": \" ");
      String str2 = localCommentMessage.srccontent;
      SpannableStringBuilder localSpannableStringBuilder3 = localSpannableStringBuilder2.append(str2).append(" \"");
      Utils.highlightContent(getContext(), localSpannableStringBuilder1);
      TextView localTextView1 = this.mSubContent;
      TextView.BufferType localBufferType1 = TextView.BufferType.SPANNABLE;
      localTextView1.setText(localSpannableStringBuilder1, localBufferType1);
      if (!paramBoolean3)
        break label337;
      TextView localTextView2 = this.mDate;
      int i = getResources().getColor(2131230720);
      localTextView2.setTextColor(i);
      label143: Context localContext = this.context;
      Date localDate = localCommentMessage.commenttime;
      String str3 = Utils.formatDate(localContext, localDate);
      TextView localTextView3 = this.mName;
      String str4 = localCommentMessage.commentnick;
      localTextView3.setText(str4);
      this.mName.getPaint().setFakeBoldText(1);
      this.mDate.setText(str3);
      localSpannableStringBuilder1.clear();
      String str5 = localCommentMessage.commentcontent;
      SpannableStringBuilder localSpannableStringBuilder4 = localSpannableStringBuilder1.append(str5);
      Utils.highlightContent(getContext(), localSpannableStringBuilder1);
      TextView localTextView4 = this.mContent;
      TextView.BufferType localBufferType2 = TextView.BufferType.SPANNABLE;
      localTextView4.setText(localSpannableStringBuilder1, localBufferType2);
      this.mPortrait.setImageBitmap(null);
      int j = paramInt;
      int k = 1;
      if (j != k)
        break label349;
      this.mPortrait.setVisibility(8);
    }
    while (true)
    {
      return;
      String str6 = getResources().getString(2131427502);
      SpannableStringBuilder localSpannableStringBuilder5 = localSpannableStringBuilder1.append(str6).append(": \" ");
      String str7 = localCommentMessage.mblogcontent;
      SpannableStringBuilder localSpannableStringBuilder6 = localSpannableStringBuilder5.append(str7).append("....  \"");
      break;
      label337: this.mDate.setTextColor(-7829368);
      break label143;
      label349: this.mPortrait.setVisibility(0);
      if (localCommentMessage.commentportrait == null)
      {
        this.mPortrait.setImageResource(2130838011);
        continue;
      }
      if (localCommentMessage.commentportrait == null)
        continue;
      this.mPortrait.setImageResource(2130838011);
      Map localMap1 = downloading;
      String str8 = localCommentMessage.commentportrait;
      if (localMap1.containsKey(str8))
        continue;
      String str9 = this.mCacheDir;
      String str10 = localCommentMessage.commentportrait;
      String str11 = Utils.checkCache(str9, str10);
      if (str11 == null)
      {
        Map localMap2 = downloading;
        String str12 = localCommentMessage.commentportrait;
        ListView localListView = this.parent;
        Object localObject = localMap2.put(str12, localListView);
        LoadPortraitTask localLoadPortraitTask = new LoadPortraitTask(null);
        String[] arrayOfString = new String[1];
        String str13 = localCommentMessage.commentportrait;
        arrayOfString[0] = str13;
        AsyncTask localAsyncTask = localLoadPortraitTask.execute(arrayOfString);
        continue;
      }
      Bitmap localBitmap1 = BitmapFactory.decodeFile(str11);
      if (localBitmap1 != null)
      {
        ImageView localImageView = this.mPortrait;
        Bitmap localBitmap2 = Utils.outputBmp(this.context, localBitmap1, 0);
        localImageView.setImageBitmap(localBitmap2);
        continue;
      }
      boolean bool = new File(str11).delete();
      displayDefaultPortrait();
    }
  }

  class LoadPortraitTask extends AsyncTask<String, Void, String[]>
  {
    private LoadPortraitTask()
    {
    }

    protected String[] doInBackground(String[] paramArrayOfString)
    {
      String[] arrayOfString = new String[2];
      String str1 = paramArrayOfString[0];
      int i = 0;
      try
      {
        RPCHelper localRPCHelper = RPCHelper.getInstance(CommentMessageListItemView.this.getContext());
        String str2 = CommentMessageListItemView.this.context.getCacheDir().getAbsolutePath();
        String str3 = localRPCHelper.getPicture(str1, str2);
        File localFile = new File(str3);
        if (localFile.exists())
        {
          String str4 = localFile.toString();
          localObject = str4;
        }
        arrayOfString[0] = str1;
        arrayOfString[1] = localObject;
        return arrayOfString;
      }
      catch (Exception localException)
      {
        while (true)
          Object localObject = null;
      }
    }

    protected void onPostExecute(String[] paramArrayOfString)
    {
      String str1 = paramArrayOfString[0];
      String str2 = paramArrayOfString[1];
      ListView localListView;
      Bitmap localBitmap1;
      int k;
      if (str2 != null)
      {
        localListView = (ListView)CommentMessageListItemView.downloading.get(str1);
        localBitmap1 = Utils.outputRoundRectBitmap(BitmapFactory.decodeFile(str2));
        int i = localListView.getFirstVisiblePosition();
        int j = localListView.getChildCount();
        k = 0;
        if (k >= j)
          Object localObject = CommentMessageListItemView.downloading.remove(str1);
      }
      else
      {
        return;
      }
      if (!(localListView.getChildAt(k) instanceof CommentMessageListItemView));
      while (true)
      {
        k += 1;
        break;
        CommentMessageListItemView localCommentMessageListItemView = (CommentMessageListItemView)localListView.getChildAt(k);
        if (!localCommentMessageListItemView.cm.commentportrait.equals(str1))
          continue;
        if (localBitmap1 != null)
        {
          ImageView localImageView = localCommentMessageListItemView.mPortrait;
          Bitmap localBitmap2 = Utils.outputBmp(CommentMessageListItemView.this.context, localBitmap1, 0);
          localImageView.setImageBitmap(localBitmap2);
          continue;
        }
        CommentMessageListItemView.this.displayDefaultPortrait();
      }
    }

    protected void onPreExecute()
    {
    }

    protected void onProgressUpdate(Void[] paramArrayOfVoid)
    {
    }
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     com.sina.weibo.view.CommentMessageListItemView
 * JD-Core Version:    0.6.0
 */